package cn.xiaosiyuan.util.validate;

import cn.xiaosiyuan.util.X;
import cn.xiaosiyuan.util.interfaces.IValidateUtil;

import java.io.File;

public class ValidateUtil implements IValidateUtil {


    private boolean validateStr(String str) {
        if (str == null) return false;
        if (str.equals("")) return false;
        return true;
    }


    @Override
    public boolean fileAbsolutePath(String absolutePath) {
        if (!validateStr(absolutePath)) return false;

        boolean rs = true;

        File file = new File(absolutePath);
        // 判断文件是否存在
        rs = file.exists();

        return rs;
    }

    @Override
    public boolean fileRelativePath(String relativePath) {
        if (!validateStr(relativePath)) return false;

        String str = relativePath;
        String path = X.pathUtil.getByRelativePath(str);

        boolean rs = true;
        File file = new File(path);
        // 判断文件是否存在
        rs = file.exists();

        return rs;
    }
}
